package com.atguigu.product.controller;

import com.atguigu.param.ProductCollectParam;
import com.atguigu.product.service.ProductService;
import com.atguigu.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName:ProductCollectController
 * Package:com.atguigu.product.controller
 * Description:
 *
 * @Author 应永豪
 * @Create 2024/4/22 16:55
 * @Version 1.0
 */
@RestController
@RequestMapping("product")
public class ProductCollectController {
    @Autowired
    private ProductService productService;

    @PostMapping("collect/list")
    public R productIds(@RequestBody @Validated ProductCollectParam param, BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            return R.fail("没有收藏数据");
        }

        return productService.ids(param.getProductIds());
    }


}
